package com.lanou.dllo.findfood.fragment;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.lanou.dllo.findfood.adpter.MenuViewPagerAdpter;
import com.lanou.dllo.findfood.R;

/**
 * Created by dllo on 15/10/23.
 */
public class CookbookFragment extends Fragment implements View.OnClickListener {
    private ViewPager viewPager;
    private TabLayout tabLayout;


    @Override
    public void onAttach(Context context) {

        super.onAttach(context);
    }


    /**
     * @param inflater
     * @param container
     * @param savedInstanceState
     * @return 加载布局
     */
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragmen_cookbook, null);

        return view;

    }


    //调用方法
    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initView();
        initData();
    }

    private void initView() {

        viewPager = (ViewPager) getActivity().findViewById(R.id.viewpage);
        tabLayout = (TabLayout) getActivity().findViewById(R.id.tablayout);
        tabLayout.setSelectedTabIndicatorColor(0Xff0088ff);//修改滑动下标的颜色
        tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
//        viewPager = (ViewPager) getActivity().findViewById(R.id.reView);


    }

    private void initData() {
        MenuViewPagerAdpter adpter = new MenuViewPagerAdpter(getActivity().
                getSupportFragmentManager());
        viewPager.setAdapter(adpter);
        tabLayout.setupWithViewPager(viewPager);


    }

    @Override
    public void onClick(View v) {

    }


}
